package com.ldzy.Utils;

import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.Reader;

public class MybatisUtils {
    private  static SqlSessionFactory sqlMappe=null;
    static {
        String resources = "mybatis-config.xml";
        Reader reader = null;
        try {
            reader = org.apache.ibatis.io.Resources.getResourceAsReader(resources);
        } catch (IOException e) {
            e.printStackTrace();
        }
        SqlSessionFactoryBuilder builder = new SqlSessionFactoryBuilder();
        sqlMappe = builder.build(reader);
    }
    public static SqlSession getSqlssion(){
        SqlSession sqlSession=sqlMappe.openSession();
        return  sqlSession;
    }
}
